package com.scproject.scbef.controller.study.politicsknowledge;

import com.scproject.annotations.LoginVerifyToken;
import com.scproject.annotations.PassToken;
import com.scproject.dto.ResponseDto;
import com.scproject.scbef.pojo.PoliticsKnowledge;
import com.scproject.scbef.service.study.politicsknowledge.PoliticsKnowLedgeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.servlet.http.HttpServletRequest;

/**
 * @author LNL
 * @date 2021/5/25 19:14
 */
@RestController
@Api(tags = "党建知识模块")
@RequestMapping("/knowledge")
public class PoliticsKnowLedgeController {

    @Autowired
    private PoliticsKnowLedgeService politicsKnowLedgeService;

    @GetMapping("/knowledges")
    @ApiOperation("获取所有党建知识")
    @PassToken
    public ResponseDto getAllPoliticsKnowledge() {
        ResponseDto responseDto = politicsKnowLedgeService.getAllPoliticsKnowledge();
        return responseDto;
    }

    @PostMapping("/delete/{id}")
    @LoginVerifyToken
    @ApiOperation("删除党建知识")
    public ResponseDto deletePoliticsKnowledge(@PathVariable("id") String id, HttpServletRequest request) {
        ResponseDto responseDto = politicsKnowLedgeService.deletePoliticsKnowledge(id,request);
        return responseDto;
    }

    @PostMapping("/insert")
    @LoginVerifyToken
    @ApiOperation("添加党建知识")
    public ResponseDto insertPoliticsKnowledge(MultipartHttpServletRequest request) {
        ResponseDto responseDto = politicsKnowLedgeService.insertPoliticsKnowledge(request);
        return responseDto;
    }

    @PostMapping("/update")
    @LoginVerifyToken
    @ApiOperation("修改党建知识")
    public ResponseDto updatePoliticsKnowledge(@RequestBody PoliticsKnowledge politicsKnowledge,HttpServletRequest request) {
        ResponseDto responseDto = politicsKnowLedgeService.updatePoliticsKnowledge(politicsKnowledge,request);
        return responseDto;
    }





}
